/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.mzk.kramerius.commons;

import org.safehaus.uuid.UUID;
import org.safehaus.uuid.UUIDGenerator;

/**
 *
 * @author Martin Rehanek (rehan@mzk.cz)
 */
public class RandomBasedUuidGenerator implements UuidGenerator {

    private static RandomBasedUuidGenerator instance = null;
    private final UUIDGenerator generator;

    public static RandomBasedUuidGenerator instanceOf() {
        if (instance == null) {
            instance = new RandomBasedUuidGenerator();
        }
        return instance;
    }

    private RandomBasedUuidGenerator(){
        generator = UUIDGenerator.getInstance();
    }

    public String generateUuid() {
        UUID generatedUuid = generator.generateRandomBasedUUID();
        return generatedUuid.toString();
    }
}
